package operations;

import book.Book;
import book.BookLiet;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookLiet bookLiet) {
        //查找图书
        System.out.println("查找图书！");
        //按照名字查找~~~
        Scanner input = new Scanner(System.in);
        System.out.println("请输入你要查找书的名字：");
        String bookName = input.nextLine();//输入书名
        int currentSize = bookLiet.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookLiet.getPos(i);
            if (bookName.equals(book.getName())) {
                System.out.println("找到了这本书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
